package ljl.bilibili.video.vo.request.video_production;

import io.swagger.annotations.ApiModelProperty;
import ljl.bilibili.entity.notice.dynamic.Dynamic;
import ljl.bilibili.entity.user_center.user_info.User;
import ljl.bilibili.entity.video.video_production.upload.Video;
import lombok.Data;
import org.springframework.beans.BeanUtils;
import org.springframework.web.multipart.MultipartFile;

/**
 * 视频上传请求类
 * 用于封装视频上传的相关信息
 */
@Data
public class UploadVideoRequest {
    @ApiModelProperty("视频路径")
    private String url;
    @ApiModelProperty("视频名称")
    private String name;
    @ApiModelProperty("视频介绍")
    private String intro;
    @ApiModelProperty("作者id")
    private int userId;
    @ApiModelProperty("视频封面")
    private String videoCover;

    /**
     * 将请求对象转换为实体对象
     */
    public Video toEntity() {
        Video video = new Video();
        BeanUtils.copyProperties(this, video);
        return video;
    }

    /**
     * 创建不含封面的动态对象
     * @param user 用户对象，用于获取作者id
     * @param video 视频对象，用于获取视频id和名称
     * @return Dynamic动态对象，包含视频id、名称和作者id
     */
    public Dynamic toNoCoverDynamic(User user, Video video){
        return new Dynamic().setVideoId(video.getId()).setVideoName(video.getName())
                .setAuthorId(user.getId());
    }

    /**
     * 创建含封面的动态对象
     */
    public Dynamic toCoverDynamic(User user, Video video){
        return new Dynamic().setVideoId(video.getId()).setVideoCover(video.getCover()).setVideoName(video.getName())
                .setAuthorId(user.getId());
    }
}